import 'package:flutter/material.dart';

/// @date 2020/08/06  15:48
/// @author 程志强
/// @des

class NotificationRoute extends StatefulWidget {
  @override
  _NotificationRouteState createState() => _NotificationRouteState();
}

class _NotificationRouteState extends State<NotificationRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("Notification"),
        ),
        body: Center(
          child: NotificationListener(
            onNotification: (notification) {
              switch (notification.runtimeType) {
                case ScrollStartNotification:
                  print("开始滚动");
                  break;
                case ScrollUpdateNotification:
                  print("正在滚动");
                  break;
                case ScrollEndNotification:
                  print("滚动停止");
                  break;
                case OverscrollNotification:
                  print("滚动到边界");
                  break;
                default:
                  break;
              }
              // 阻止冒泡
              return false;
            },
            child: ListView.builder(
                itemCount: 100,
                itemBuilder: (context, index) {
                  return ListTile(
                    title: Text("$index"),
                  );
                }),
          ),
        ));
  }
}
